﻿using Kernel.EF.Demo.OData;
using Kernel.EF.Demo.Sqlite;
using Microsoft.EntityFrameworkCore;

namespace WebAPI.Configure;

public static class EFDbContextExtensions
{
    public static void AddBuildinEntityFramework(this IServiceCollection services, IConfiguration configuration)
    {
        services.AddDbContext<MyDataContext>(option => option.UseInMemoryDatabase("MyDataContextList"));
        services.AddDbContext<KernelAPIContext>(option => option.UseSqlite(string.Format(configuration.GetSection("DBConnction:SqliteConnection").Value, Config.SettingFolder)));
    }

    public static void UseBuildinEntityFramework(this IApplicationBuilder app)
    {
        //var reportServerContext = ServiceHost.GetService<ReportServerContext>();
        //reportServerContext.Database.EnsureCreated();//数据库不存在的话，会自动创建
    }

}

